package xyz.liuz.edb;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;

import java.util.concurrent.TimeUnit;

public class ServiceServerChannelInitializer extends ChannelInitializer<SocketChannel> {


    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
//        pipeline.addLast("StringEncoder",new StringEncoder(CharsetUtil.UTF_8));
        pipeline.addLast("StringEncoder",new ServiceEncoder());
        pipeline.addLast(new IdleStateHandler(10, 0, 0, TimeUnit.SECONDS));
        pipeline.addLast("ServiceProtocoDecoder",new ServiceProtocolDecoder());
//        pipeline.addLast(new IdleStateHandler(10, 5, 20, TimeUnit.SECONDS));
        pipeline.addLast("ServiceServerHandler",new ServiceServerHandler());
    }
}
